<template>
  <a-modal
    :visible="visible"
    :afterClose="hanldeAfterClose"
    @cancel="close"
    @ok="close"
    :width="1200"
    title="查看信息">
    <a-spin :spinning="spinning">
      <a-descriptions bordered>
        <a-descriptions-item label="申请编号">
          {{ dataInfo.ApplyNo }}
        </a-descriptions-item>
        <a-descriptions-item label="姓名">
          {{ dataInfo.Name }}
        </a-descriptions-item>
        <a-descriptions-item label="身份证">
          {{ dataInfo.IDCard }}
        </a-descriptions-item>
        <a-descriptions-item label="性别">
          {{ dataInfo.IDCard | sexForIDCard }}
        </a-descriptions-item>
        <!-- <a-descriptions-item label="婚姻状况">
          {{ dataInfo.IDCard }}
        </a-descriptions-item> -->
        <a-descriptions-item label="电话号码">
          {{ dataInfo.Tel }}
        </a-descriptions-item>
        <a-descriptions-item label="保障方式">
          {{ data.ApplyClass }}
        </a-descriptions-item>
        <a-descriptions-item label="户籍所在地" :span="3">
          {{ dataInfo.CensusRegAddress }}
        </a-descriptions-item>
        <a-descriptions-item label="预分配地址" :span="3">
          {{ dataInfo.EAddress }}
        </a-descriptions-item>
        <a-descriptions-item label="房屋面积"> {{ dataInfo.BuilderArea }}㎡ </a-descriptions-item>
        <!-- <a-descriptions-item label="房屋户型">
        </a-descriptions-item> -->
        <a-descriptions-item label="预分配时间">
          {{ data.EsetDate | moment('YYYY-MM-DD') }}
        </a-descriptions-item>
      </a-descriptions>
    </a-spin>
  </a-modal>
</template>

<script>
import { getSignContractMode } from '@/api/followUpManagement'
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    data: {
      type: Object,
      default: () => {}
    }
  },
  watch: {
    visible (n) {
      if (n) {
        this.fetchData()
      }
    }
  },
  filters: {
    sexForIDCard (IDCard) {
      if (!IDCard) return ''
      const sexNumber = IDCard.charAt(16)
      return sexNumber % 2 === 0 ? '女' : '男'
    }
  },
  data () {
    return {
      dataInfo: {},
      spinning: false
    }
  },
  methods: {
    fetchData () {
      this.spinning = true
      getSignContractMode({ ID: this.data.ID })
        .then((res) => {
          this.dataInfo = res
        })
        .finally(() => {
          this.spinning = false
        })
    },
    close () {
      this.$emit('update:visible', false)
      this.$emit('update:data', {})
      this.dataInfo = {}
    },
    hanldeAfterClose () {}
  }
}
</script>
<style lang="less" scoped>
</style>
